home *** CD-ROM | disk | FTP | other *** search
Text File | 1999-06-23 | 2.0 KB | 85 lines | [TEXT/CWIE] |
- // ===========================================================================
- // CFlipBehavior.cp ©1999 Eric Traut
- // ===========================================================================
-
- #include "CFlipBehavior.h"
- #include "CShadowWindow.h"
-
-
- // ---------------------------------------------------------------------------
- // • CFlipBehavior
- // ---------------------------------------------------------------------------
-
- CFlipBehavior::CFlipBehavior(
- CShadowWindow & inShadowWindow,
- Boolean inHorizontal)
- : COffscreenBehavior(inShadowWindow, true)
- {
- mHorizontal = inHorizontal;
- }
-
-
- // ---------------------------------------------------------------------------
- // • RenderToGWorld
- // ---------------------------------------------------------------------------
-
- Boolean
- CFlipBehavior::RenderToGWorld(
- StGWorldLocker & inBackingLocker,
- StGWorldLocker & inRenderingLocker)
- {
- UInt16 row;
- UInt16 column;
- UInt16 maxRow;
- UInt16 maxColumn;
- UInt16 srcRowWords;
- UInt16 destRowWords;
- UInt16 * srcRowPtr;
- UInt16 * destRowPtr;
- PixMapPtr tempPixMap;
-
- tempPixMap = *inBackingLocker.GetPixMap();
- srcRowWords = (tempPixMap->rowBytes & 0x3FFF) / 2;
- srcRowPtr = reinterpret_cast<UInt16 *>(tempPixMap->baseAddr);
-
- tempPixMap = *inRenderingLocker.GetPixMap();
- destRowWords = (tempPixMap->rowBytes & 0x3FFF) / 2;
- destRowPtr = reinterpret_cast<UInt16 *>(tempPixMap->baseAddr);
-
- maxRow = tempPixMap->bounds.bottom - tempPixMap->bounds.top;
- maxColumn = tempPixMap->bounds.right - tempPixMap->bounds.left;
-
- if (mHorizontal)
- {
- // Flip horizontal
- for (row = 0; row < maxRow; row++)
- {
- for (column = 0; column < maxColumn; column++)
- {
- destRowPtr[column] = srcRowPtr[maxColumn - column - 1];
- }
-
- srcRowPtr += srcRowWords;
- destRowPtr += destRowWords;
- }
- }
- else
- {
- // Flip vertical
- for (column = 0; column < maxColumn; column++)
- {
- for (row = 0; row < maxRow; row++)
- {
- destRowPtr[row * destRowWords] = srcRowPtr[(maxRow - row - 1) * srcRowWords];
- }
-
- srcRowPtr++;
- destRowPtr++;
- }
- }
-
- return true;
- }
-
-
-